/*
 * $Id: MagmonDataSetBuilder.java,v 1.1 2009/06/18 19:55:20 afaichun Exp $
 * 
 * Copyright (C) 2008 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.processor.shemjob.guidance.builder;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

import com.ge.healthcare.autosc.common.exceptions.BasicException;
import com.ge.healthcare.autosc.common.util.xml.dom.DomHelper;
import com.ge.healthcare.autosc.processor.shemjob.guidance.dataset.MagmonDataSet;
import com.ge.healthcare.autosc.processor.shemjob.guidance.loader.IGuidanceLoader;

public class MagmonDataSetBuilder implements IGuidanceElementBuilder {

    /**
     * Build a single element for a configuration hash table.  The element
     *  represents the specified node.  Because a validating parser has
     *  been used, the types and values of the underlying nodes have been
     *  checked as much as possible by the parser.
     *
     * @param nodeLabel The XML label for the node being represented by
     *  the element.
     *
     * @param configNode The node which encodes the configuration element.
     *
     * @param domHolder The object holding the DOM containing the node.
     *  This is used to process the node.
     *
     * @return The object to insert into the hash table.
     *
     * @exception Exception If an error is detected.  The error will
     *  be logged by the caller.
     */
    public Object buildElement( String nodeLabel, Node configNode, IGuidanceLoader loader) 
    	throws BasicException {
        Element functionElement = DomHelper.getSingleChildElementFor( configNode );
        String functionName = functionElement.getTagName();
        String[] argList = DomHelper.getTextItemsFor( functionElement );
        return new MagmonDataSet( functionName, argList );
    }
}
